<include file="header" />
<div id="content">
    <menu id="publicmenu">
        <div class="pure-menu pure-menu-open">
            <ul>
                <li>
                    <a href="{:U('w3g/Public/home')}">
                        <div class="sidebar-ico sidebar-home"></div>
                        <div>广场</div>
                    </a>
                </li>
                <li class="pure-menu-selected">
                    <a href="#login">
                        <div class="sidebar-ico sidebar-login"></div>
                        <div>登录</div>
                    </a>
                </li>
                <li>
                    <a href="{:U('w3g/Public/register')}">
                        <div class="sidebar-ico sidebar-register"></div>
                        <div>注册帐号</div>
                    </a>
                </li>
                <li>
                    <a href="{:U('w3g/Public/about')}">
                        <div class="sidebar-ico sidebar-about"></div>
                        <div>关于我们</div>
                    </a>
                </li>
            </ul>
        </div>
    </menu>
    <div id="reset" class="panel pure-form pure-form-stacked ts-padding20" selected="true" data-footer="none" data-menu="publicmenu" data-onload="$.ui.squareContainer();">
        <form class="pure-form">
            <fieldset class="pure-group">
                <input id="password" name="password" type="password" class="pure-input-1" placeholder="密码为6-15位，字母、数字、符号组成"/>
                <input id="repassword" name="repassword" type="password" class="pure-input-1" placeholder="重复密码"/>
                <input id="code" type="hidden" name="code" value="{$code}"/>
            </fieldset>
        </form>
        <input id="reset-input-submit" type="submit" value="确定" class="pure-input-1 pure-button pure-button-primary" data-ignore="true" onclick="resetPass()" />



        <div class="pure-g" id="login-toggle-link">
            <div class="pure-u-1-2 text-left">
                <a href="{:U('w3g/Public/register')}">注册新帐号</a>
            </div>
            <div class="pure-u-1-2 text-right">
                <a href="{:U('w3g/Public/login')}">登录</a>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        var resetPass = function(){
            var password = $('#password').val();
            var repassword = $('#repassword').val();
            var code = $('#code').val();
            var subbtn = $('#reset-input-submit');
            if(password == ''){
                $.ui.showMask("请输入密码", true);
                return;
            }
            if(!TS.r.password(password)){
                $.ui.showMask("密码格式不正确", true);
                return;
            }
            if(password != repassword){
                $.ui.showMask("两次密码输入不一致", true);
                return;
            }
            subbtn.attr('disabled', true);
            //提交注册
             $.ajax({
                type:"POST",
                url :U('w3g/Public/doResetPassword'),
                data:{"code":code,"password":password,"repassword":repassword},
                timeout:10000,
                dataType:"json",
                success:function(w){
                    if(w.flag == 0){
                        $.ui.showMask(w.msg, true); 
                        subbtn.attr('disabled', false);
                    }else{
                        $.ui.showMask("成功设置新密码", true);
                        subbtn.attr('disabled', true);
                        window.location.href= w.jump;
                    }
                },
                error:function(xhr,type){
                    $.ui.showMask("连接服务器失败，请重试:)",true);
                     subbtn.attr('disabled', false);
                }
            });
        };
    </script>
<include file="footer_public" />